package com.github.rxyor.ddd.service.infrastructure.repository.dao.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.rxyor.ddd.service.infrastructure.repository.dao.OrderAddressDAO;
import com.github.rxyor.ddd.service.infrastructure.repository.entity.OrderAddressDO;
import com.github.rxyor.ddd.service.infrastructure.repository.mapper.OrderAddressMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Repository;

/**
 *<p>
 *
 *</p>
 *
 * @author liuyang
 * @date 2019/10/3 周四 16:11:00
 * @since 1.0.0
 */
@AllArgsConstructor
@Repository("orderAddressDAO")
public class OrderAddressDAOImpl implements OrderAddressDAO {

    private final OrderAddressMapper orderAddressMapper;

    @Override
    public OrderAddressMapper getMapper() {
        return orderAddressMapper;
    }

    @Override
    public OrderAddressDO selectByOrderId(Long orderId) {
        if (orderId == null) {
            return null;
        }
        Wrapper<OrderAddressDO> wrapper = Wrappers.<OrderAddressDO>lambdaQuery()
            .ge(orderId != null, OrderAddressDO::getOrderId, orderId);
        return orderAddressMapper.selectOne(wrapper);
    }
}
